<!DOCTYPE html>
<html>
<head>
    <meta charset='UTF-8'>
    <title>key的原理</title>
    <script src="../js/vue.js"></script>
</head>
<body>
    <div id="root">
        <!-- 遍历数组 -->
        <h2>光与夜之恋</h2>
        <button @click.once="add">添加</button>
        <ul>
            <li v-for="(p ,index) in persons" :key="p.id">
                {{p.name}}-{{p.des}}
                <input type="text">
            </li>
        </ul>
    </div>
</body>
<!--   JS   -->
    <script>
        new Vue({
            el:'#root',
            data:{
                persons:[
                    {id:'001',name:'陆沉',des:'万甄总裁CEO'},
                    {id:'002',name:'查里苏',des:'财阀之子'},
                    {id:'003',name:'齐司礼',des:'狐狐老婆>_<'}
                ],
            },
            methods: {
                add(){
                    const p ={id:'004',name:'萧逸',des:'赛车手'}
                    this.persons.unshift(p)
                }
            },

        })
    </script>
</html>